package com.ocean.nc.task;

import com.alibaba.fastjson2.JSON;
import com.ocean.common.utils.StringUtils;
import com.ocean.common.utils.YamlUtil;
import com.ocean.historyProduct.service.IOHistoryProductService;
import com.ocean.nc.domain.NamedCoordinate;
import com.ocean.nc.domain.NamedTemperatureResult;
import com.ocean.nc.service.IONcFileService;
import com.ocean.product.service.IOProductService;
import com.ocean.productCheck.domain.OProductCheckSms;
import com.ocean.productCheck.service.IOProductCheckSmsService;
import com.ocean.productDict.domain.OZnwgSt;
import com.ocean.productDict.domain.oNcfileMonitor;
import com.ocean.productDict.service.oNcfileMonitorService;
import com.ocean.productRelease.service.IOProductReleaseService;
import com.ocean.system.domain.OProductSmsphone;
import com.ocean.system.service.IOProductSmsphoneService;
import com.ocean.system.service.ISysConfigService;
import com.ocean.workOrder.service.IOWorkOrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import ucar.ma2.Array;
import ucar.ma2.InvalidRangeException;
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import util.ZnwgTool;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

import static util.CppgjyUtil.getNamedSeaTemperatures;
import static util.SMSSender.sendSMS;

@Component("FileTask")
@Slf4j
public class AutoFileTask {

            @Autowired
            private IONcFileService ncFileService;

            @Autowired
            private IOProductReleaseService productReleaseService;

            @Autowired
            private IOWorkOrderService workOrderService;

            @Autowired
            private IOProductService productService;

            @Autowired
            private IOHistoryProductService historyProductService;

            @Autowired
            private oNcfileMonitorService oNcfileMonitorService;

            @Autowired
            private ISysConfigService configService;

            @Autowired
            private IOProductSmsphoneService oProductSmsphoneService;

            @Autowired
            private IOProductCheckSmsService checkSmsService;


            /**
             * 自动归档每20秒执行一次
             */
            //@Scheduled(cron = "0/20 * * * * ?")
            public void run() {
                String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
                //非任务服务器
                if (!"true".equals(isFile)) {
                    return;
                }

                long start = System.currentTimeMillis();
                log.info("===================自动归档开始===================");
                try {
                    this.ncFileService.autoFile();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                log.info("===================自动归档结束===================");
                long end = System.currentTimeMillis();
                long times = end - start;
                log.info("总耗时" + times + "毫秒");
            }

            //每天23点执行
            @Scheduled(cron = "0 0 23 * * ?")
            public void deleteFile() {
            String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
            //非任务服务器
            if (!"true".equals(isFile)) {
                return;
            }
            long start = System.currentTimeMillis();
            log.info("===================删除文件开始===================");
            try {
                productReleaseService.deleteFile();
            } catch (Exception e) {
                e.printStackTrace();
        }
        log.info("===================删除文件结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }

    /**
     * 每天凌晨一点查询订阅单状态进行更新
     */
    //@Scheduled(cron = "0 0 1 * * ?")
    @Scheduled(cron = "0 */10 * * * ?")//每十分钟更新一次
    public void autoUpdateWorkStatus() {
        String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
        //非任务服务器
        if (!"true".equals(isFile)) {
            return;
        }
        //每天凌晨1点执行
        long start = System.currentTimeMillis();
        log.info("===================更新任务单状态开始===================");
        try {
            this.workOrderService.autoUpdateWorkStatus();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================更新任务单状态结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }

    /**
     * 校验nc文件是否归档
     */
/*    @Scheduled(cron = "0 0/1 * * * ?")
    //@Scheduled(cron = "0/20 * * * * ?")//测试使用20秒执行一次
   // 0 0 23 * * ?
    public void checkNcFile() {
        String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
        //非任务服务器
        if (!"true".equals(isFile)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================校验nc文件是否归档开始===================");
        try {
            this.productService.checkNcFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================校验nc文件是否归档结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }*/

    /**
     * 每天上午九点检测订阅快到期的用户,检测时间三天内到期
     */
    @Scheduled(cron = "0 0 9 * * ?")
    //@Scheduled(cron = "0/20 * * * * ?")//测试使用
    public void checkSubscribeTime() {
        String isCheck = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_check_subscribe_time");
        //非任务服务器
        if (!"true".equals(isCheck)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================检查订阅到期时间开始===================");
        try {
            this.productService.checkSubscribeTime();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================检查订阅到期时间结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }

    /**
     * 每晚0点1分检查未更新产品,超过期限未更新产品加入历史产品表
     */
    @Scheduled(cron = "0 1 0 * * ?")
//    @Scheduled(cron = "0 0/1 * * * ?")
    public void checkNotUpdateProduct() {
        String isCheck = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_check_not_update_product");
        //非任务服务器
        if (!"true".equals(isCheck)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================检查产品未更新过期时间开始===================");
        try {
            this.historyProductService.checkNotUpdateProduct();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================检查产品未更新过期时间结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }

    /**
     * 检查产品晚传
     */
    //@Scheduled(cron = "0 0/1 * * * ?")
    //@Scheduled(cron = "0/20 * * * * ?")//测试使用
    public void checkProductLateUpload() {
        String isCheck = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_check_upload_overtime");
        // 非任务服务器
        if (!"true".equals(isCheck)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================检查产品是否晚传开始===================");
        try {
            this.productService.checkLateTransmission();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================检查产品是否晚传结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");
    }

    /**
     * 检查产品补传
     */
//    @Scheduled(cron = "0 1 0/1 * * ?")
    @Scheduled(cron = "0 0/30 * * * ? ")
    public void checkProductRepairUpload() {
       /* String isCheck = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_check_upload_overtime");
        //非任务服务器
        if (!"true".equals(isCheck)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================检查产品是否补传开始===================");
        try {
            this.productService.checkRepairTransmission();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================检查产品是否补传结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");*/
    }

    /**
     * 检查c++解压生成的xml，对解压文件入库
     */
    @Scheduled(cron = "0 0/10 * * * ?")
    public void fileConversionNC() {
      /*  String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
        // 非任务服务器
        if (!StringUtils.equals("true", isFile)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================解析NC转换结果xml开始===================");
        try {
            ncFileService.checkNCXml();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================解析NC转换结果xml结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");*/
    }


//    @Scheduled(cron = "0 0/1 * * * ?")
    public void imageRun() {
      /*  String isFile = (String) YamlUtil.loadYaml("sysConfig.yaml").get("is_task");
        //非任务服务器
        if (!StringUtils.equals("true", isFile)) {
            return;
        }
        long start = System.currentTimeMillis();
        log.info("===================自动归档图片开始===================");
        try {
//            this.ncFileService.autoImage();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("===================自动归档图片结束===================");
        long end = System.currentTimeMillis();
        long times = end - start;
        log.info("总耗时" + times + "毫秒");*/
    }

    /**
     * 定时任务：监听智能网格L0L4L5级产品报道情况
     */
    public void ZnwgL045(){
        JianKong("znwgl045");
    }

    /**
     * 定时任务：监听智能网格L1级产品报道情况
     */
    public void ZnwgL1(){
        JianKong("znwgl1");
    }

    /**
     * 定时任务：监听智能网格L2L3级产品报道情况
     */
    public void ZnwgL23(){
        JianKong("znwgl23");
    }


    /**
     * 监控
     * @param ml 目录
     */
    public void JianKong(String ml){
        System.out.println("============="+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))+"定时任务：监听智能网格"+ml+"级产品报道情况==================");
        String znwgjkftp = configService.selectConfigByKey("znwgjkftp");
        String server = znwgjkftp; // FTP服务器地址
        String znwgjkftpdk = configService.selectConfigByKey("znwgjkftpdk");
        int port = Integer.parseInt(znwgjkftpdk); // FTP服务器端口
        String znwgjkftpuser = configService.selectConfigByKey("znwgjkftpuser");
        String user = znwgjkftpuser; // FTP登录用户名
        String znwgjkftppwd = configService.selectConfigByKey("znwgjkftppwd");
        String pass = znwgjkftppwd; // FTP登录密码
        System.out.println("ftp登录中"+znwgjkftpuser);
        FTPClient ftpClient = new FTPClient();
        try {
            ftpClient.connect(server, port);
            boolean login = ftpClient.login(user, pass);

            if (!login) {
                System.out.println("Login failed");
                ftpClient.disconnect();
                return;
            }
            System.out.println("登录成功！");
            List<String> listdata= oNcfileMonitorService.getDtdata();//查询当天的数据
            String[] path = configService.selectConfigByKey(ml).split(",");//获取目录
            ftpClient.setConnectTimeout(15000);    // 连接建立超时
            ftpClient.setDataTimeout(60000);       // 数据传输超时
            ftpClient.setDefaultTimeout(30000);    // 控制通道超时
            for (int j = 0; j < path.length; j++) {
                // 切换到指定目录（可选）
                boolean b = ftpClient.changeWorkingDirectory(path[j]);//切换到L1目录
                ftpClient.enterLocalPassiveMode();//被动模式
                if(b==true){
                    System.out.println("进入目录成功");
                }
                // 获取当前日期的开始和结束时间
                Calendar cal = Calendar.getInstance();
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                Date startOfDay = cal.getTime();
                cal.add(Calendar.DAY_OF_YEAR, 1);
                Date endOfDay = cal.getTime();

                // 列出目录中的文件
                String dtwj = "";//打印当天文件
                FTPFile[] files = ftpClient.listFiles();
                int length = files.length;
                for (FTPFile file : files) {
                    if (!ftpClient.isConnected()) {//查看连接是否处于活跃状态
                        ftpClient.connect(server, port); // 重新连接
                    }
                    if (file.isFile()) {
                        Date fileTimestamp = file.getTimestamp().getTime();
                        if (fileTimestamp != null && !fileTimestamp.before(startOfDay) && !fileTimestamp.after(endOfDay)) {//判断是否是当天的数据，如果是进行入库
                            // 文件是在今天上传的
                            System.out.println(file.getName());
                            //if(file.getName().contains(jb)){
                                //oNcfileMonitor filename= oNcfileMonitorService.getisName(file.getName());//查看当前文件是否存在，是否入库
                            String substring = file.getName().substring(file.getName().length() - 3, file.getName().length());
                            if(!substring.equals("tmp")){//过滤掉缓冲文件
                                boolean contains = listdata.contains(file.getName());
                                System.out.println(contains);
                                if(!contains){//如果存在就证明已入库//如果不等于null 证明已经入过库

                                    oNcfileMonitor nc = new oNcfileMonitor();
                                    nc.setFilename(file.getName());//文件名
                                    nc.setFilepath(path[j]+"/"+file.getName());//文件路径
                                    nc.setFilesize((String.valueOf(file.getSize()/1024L * 1024L)));//文件大小M
                                    nc.setRktime(new Date());//入库时间
                                    nc.setRknf(String.valueOf(LocalDate.now().getYear()));//获取年
                                    nc.setRkyf(String.valueOf(LocalDate.now().getMonthValue()));//获取月
                                    nc.setRkrq(String.valueOf(LocalDate.now().getDayOfMonth()));//获取日
                                    nc.setLjb(ZnwgTool.getL(file.getName()));//文件L级别
                                    String[] split = file.getName().split("_");
                                    OZnwgSt st = oNcfileMonitorService.getst(split[0],ZnwgTool.getL(file.getName()));//获取省台名称
                                    if(st!=null) {
                                        nc.setFilest(st.getName());//如果不为空就存入省台名称
                                        String uptime = st.getUptime();//上传时间
                                        int uptime1 = Integer.parseInt(uptime);
                                        String hctime = st.getHctime();//缓冲时间
                                        int hctime1 = Integer.parseInt(hctime);
                                        if(hctime1>60){
                                            // 将分钟转换成小时
                                            int hours = hctime1 / 60;
                                            // 计算剩余的分钟数
                                            int minutes = hctime1 % 60;
                                            uptime1 = uptime1+hours;
                                            hctime1 = minutes;
                                        }


                                        // 获取当前时间
                                        LocalTime now = LocalTime.now();
                                        // 创建一个表示10点20分的时间对象
                                        LocalTime tenTwenty = LocalTime.of(uptime1,hctime1);
                                        if (now.isAfter(tenTwenty) || now.equals(tenTwenty)) {
                                            System.out.println("当前时间已经过了");
                                            nc.setZt(1);//晚传
                                            List<OProductSmsphone> p = oProductSmsphoneService.selectByPid(String.valueOf(st.getId()));//获取当前产品发送人
                                            if(p.size()>0){//联系人不为空
                                                String fsr = "";
                                                for (int h = 0; h < p.size(); h++) {
                                                    fsr += p.get(h).getPhone()+";";
                                                }
                                                String phones = fsr.substring(0, fsr.length() - 1);
                                                String missionName = "任务";
                                                String groupNames = "";
                                                String departmentNames = "";
                                                String tmpPhoneNum = phones;

                                                String content = "《" + st.getName() + "》负责人您好，您的产品文件"
                                                        + file.getName() + "超过上传检查时间，请在每天"+uptime+"点前上传";
                                                if(st.getIsopendx() == 1){//判断智能网格产品是否开启允许发送短信
                                                    String response = sendSMS(missionName, groupNames, departmentNames, tmpPhoneNum, content);
                                                    Map parse = (Map) JSON.parse(response);
                                                    String code = (String)parse.get("ResultCode");
                                                    if(code.equals("0")){
                                                        System.out.println("发送成功");
                                                        OProductCheckSms sms = new OProductCheckSms();
                                                        sms.setProductName(st.getName());//产品名称
                                                        sms.setProductId(p.get(0).getProductId());
                                                        sms.setCreateDate(new Date());//提醒日期
                                                        sms.setDepartId(null);//所属部门
                                                        sms.setTipTypes(1);//晚传提醒
                                                        sms.setSmsSendStatusContent(content);//提醒内容
                                                        int ok = checkSmsService.insertOProductCheckSms(sms);
                                                        System.out.println(ok);
                                                    }
                                                }
                                            }
                                        } else {
                                            nc.setZt(0);//正常到
                                        }
                                    }else{
                                        nc.setFilest("未知");//为空就未知
                                    }
                                    OZnwgSt ys = oNcfileMonitorService.getys(split[6]);//获取要素
                                    if(st!=null) {
                                        nc.setFiletype(ys.getName());//如果不为空就存入要素名称
                                    }else{
                                        nc.setFiletype("未知");//为空就未知
                                    }
                                    nc.setXzzt(0);//设置文件在服务器状态是否下载到当前服务器，只有下载到当前服务器才可以预览
                                    int i =oNcfileMonitorService.addncfile(nc);
                                    dtwj +="【"+file.getName()+"】";
                                    Integer id = nc.getId();
                                }
                            }
                        }
                    }
                }
                System.out.println("=============执行结束："+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))+"定时任务：监听智能网格L0级产品报道情况==================");

            }
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (ftpClient.isConnected()) {
                    ftpClient.logout();
                    ftpClient.disconnect();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    /**
     * 定时下载智能网格数据
     */
         public void get045(){
             String[] path = configService.selectConfigByKey("znwgl045").split(",");//获取目录
             for (int i = 0; i < path.length; i++) {
                 DSgetZnwgdata(path[i]);
             }
         }
    /**
     * 定时下载智能网格数据
     */
    public void get1(){
        String[] path = configService.selectConfigByKey("znwgl1").split(",");//获取目录
        for (int i = 0; i < path.length; i++) {
            DSgetZnwgdata(path[i]);
        }
    }
    public void get23(){
        String[] path = configService.selectConfigByKey("znwgl23").split(",");//获取目录
        for (int i = 0; i < path.length; i++) {
            DSgetZnwgdata(path[i]);
        }
    }

    public void DSgetZnwgdata(String path){//任务 查询当天没有复制到本地的文件进行复制并根据文件名把数据库的数据状态改为成功可预览
        String LOCAL_DIR = "";
        //归档服务器路径是 win 还是 linux
        String archive = (String) YamlUtil.loadYaml("sysConfig.yaml").get("archive");
        if(archive.equals("win")){
             LOCAL_DIR = configService.selectConfigByKey("gdlinuxpathh");//普通产品归档后路径
        }else{//判断是否为linux系统
             LOCAL_DIR = configService.selectConfigByKey("gdlinuxpathh");//普通产品归档后路径
        }
        String znwgjkftp = configService.selectConfigByKey("znwgjkftp");
        String server = znwgjkftp; // FTP服务器地址
        String znwgjkftpdk = configService.selectConfigByKey("znwgjkftpdk");
        int port = Integer.parseInt(znwgjkftpdk); // FTP服务器端口
        String znwgjkftpuser = configService.selectConfigByKey("znwgjkftpuser");
        String user = znwgjkftpuser; // FTP登录用户名
        String znwgjkftppwd = configService.selectConfigByKey("znwgjkftppwd");
        String pass = znwgjkftppwd; // FTP登录密码

        FTPClient ftp = new FTPClient();
        try {
            // 1. 连接并登录
            ftp.connect(server, port);
            checkReply(ftp, "连接");

            if (!ftp.login(user, pass)) {
                throw new FTPConnectionClosedException("登录失败: 检查用户名密码");
            }
            checkReply(ftp, "登录");

            // 2. 配置参数
            ftp.enterLocalPassiveMode();   // 被动模式
            ftp.setFileType(FTP.BINARY_FILE_TYPE);  // 二进制传输
            ftp.setDataTimeout(30_000);    // 30秒超时

            // 3. 进入目标目录
            if (!ftp.changeWorkingDirectory(path)) {
                throw new IOException("目录不存在: " + path);
            }

            // 4. 获取文件列表
            FTPFile[] files = ftp.listFiles();
            if (files.length == 0) {
                System.out.println("目录为空");
                return;
            }

            // 5. 批量下载文件
            for (FTPFile file : files) {
                // 6. 创建本地目录
                String[] split = file.getName().split("_");
                String pathwj = LOCAL_DIR+split[0]+"/"+split[1]+"/"+split[2]+"/"+split[3];
                new File(pathwj).mkdirs();
                oNcfileMonitor data = oNcfileMonitorService.getName(file.getName());//根据文件名查询状态为0 当天
                if(data != null){
                    if (file.isFile()) {
                        downloadFile(ftp, file.getName(),file.getSize(),file.getName(),pathwj);
                    }
                }
            }

        } catch (IOException e) {
            System.err.println("操作失败: " + e.getMessage());
            e.printStackTrace();
        } finally {
            // 7. 清理连接
            try {
                if (ftp.isConnected()) {
                    ftp.logout();
                    ftp.disconnect();
                }
            } catch (IOException e) {
                // 忽略关闭连接时的异常
            }
        }
    }


    // 文件下载核心方法（带进度监听）
    public void downloadFile(FTPClient ftp, String remoteFile,Long size,String filename,String pathwj) throws IOException {
        int i1 =oNcfileMonitorService.upztName(filename,1);
        String localPath = pathwj +"/"+ remoteFile;
        long totalSize = size;

        try (OutputStream output = new BufferedOutputStream(new FileOutputStream(localPath))) {
            // 进度回调接口（示例：打印进度条）
            ProgressListener listener = (transferred, total) -> {
                double percent = transferred * 100.0 / total;
                System.out.printf("\r%s: %.1f%% [%d/%d]",
                        remoteFile, percent, transferred, total);
            };

            // 开始下载
            try (InputStream input = ftp.retrieveFileStream(remoteFile)) {
                if (input == null) {
                    throw new IOException("无法获取文件流: " + remoteFile);
                }

                byte[] buffer = new byte[4096];
                int bytesRead;
                long transferred = 0;

                while ((bytesRead = input.read(buffer)) != -1) {
                    output.write(buffer, 0, bytesRead);
                    transferred += bytesRead;

                    // 触发进度更新
                    if (listener != null) {
                        listener.onProgress(transferred, totalSize);
                    }
                }
            }
            System.out.println(); // 换行完成进度条
            ftp.completePendingCommand(); // 必须调用以结束文件传输
            int i =oNcfileMonitorService.upztName(filename,2);
        }
    }
    // 检查FTP操作是否成功
    private static void checkReply(FTPClient ftp, String operation) throws IOException {
        if (FTPReply.isNegativePermanent(ftp.getReplyCode())) {
            throw new FTPConnectionClosedException(operation + "失败: " + ftp.getReplyString());
        }
    }

    // 进度监听接口（可选）
    @FunctionalInterface
    public interface ProgressListener {
        void onProgress(long transferredBytes, long totalBytes);
    }


    //======================================================产品评估检验西北太海温===========================================================

    public static void main(String[] args) {
        // 示例用法
        String ncFilePath = "E:\\项目资料备份\\新云平台文件\\2025工作\\西北太海温\\NMF_BEN_OSMTSCB_NWPACDT_2025090812_168h_SWT.nc";
        int timeIndex = 0;  // 时间索引
        int zIndex = 0;     // 深度索引

        // 创建多个带名称的经纬度点列表
        List<NamedCoordinate> coordinates = new ArrayList<>();
        coordinates.add(new NamedCoordinate("观测点A", 130.0, 20.0));
        coordinates.add(new NamedCoordinate("观测点B", 135.5, 25.3));
        coordinates.add(new NamedCoordinate("观测点C", 140.2, 30.1));
        coordinates.add(new NamedCoordinate("观测点D", 145.7, 35.6));
        coordinates.add(new NamedCoordinate("观测点E", 150.3, 40.2));

        // 批量获取海温数据
        List<NamedTemperatureResult> results = getNamedSeaTemperatures(
                ncFilePath, coordinates, timeIndex, zIndex);

        // 打印结果
        System.out.println("海温查询结果：");
        for (NamedTemperatureResult result : results) {
            System.out.println(result);
        }
    }
    //======================================================产品评估检验西北太海温===========================================================
}
